package ru.ifmo.croak.impl.storage.team1;

import ru.ifmo.croak.api.Message;

import java.util.Set;

/**
 * @author Alex Vikharev
 *         27.05.11
 */
public class TokenizedMessage extends Message {
    Set<String> tokens;

    public TokenizedMessage(final Message message) {
        this.setId(message.getId());
        this.setAuthor(message.getAuthor());
        this.setText(message.getText());
        this.setTime(message.getTime());
    }

    public Set<String> getTokens() {
        if(tokens == null){
            tokens = Pattern.split(getText());
        }
        return tokens;
    }
}
